package memory;

import java.io.Serializable;
import javax.swing.JLabel;
import javax.swing.JPanel;

import memory.net.ObjectDB;


@SuppressWarnings("serial")
public class Player extends JPanel implements Serializable {
	
	private JLabel name;
	private JLabel score = new JLabel("0",JLabel.LEFT);
		
	//Used for network games
	private int id = ObjectDB.getID();
	
	public Player( String playerName ) {
		
		name = new JLabel( playerName.trim(), JLabel.LEFT );
				
		this.add(name);
		this.add(score);
				
				
	}
	
	public int getID() {
		return id;
	}
	
	public String getPlayerName() {
		return name.getText();
	}
	
	public int getPlayerScore() {
		return Integer.parseInt(score.getText());
	}
	
	public void incScore( int n ) {
		int newScore = Integer.parseInt(score.getText()) + n;
		score.setText( String.valueOf(newScore) );
	}
	
}
